
<div class="st-form-line">
    <form>
        <input id="uploadify" name="uploadify" type="file" multiple="false">
        <ul id="fileListWarp">
        </ul>
        <div id="fileQueue" style="clear:both"></div>
    </form>
</div>
<script type="text/javascript">

    $(function() {
        $('#uploadify').uploadify({
            'buttonText': '选择文件..',
            'fileObjName': 'imgFile',
            'method': 'post',
            'multi': false,
            'queueID': 'fileQueue',
            'uploadLimit': 1,
            'fileTypeExts': '*.gif;*.png;*.jpg;*.bmp;',
            'buttonImage': '<?php echo $this->baseUrl; ?>/upload/js/uploadify/select.png',
            'formData': {
                'sessionId'   : '<?php echo session_id(); ?>',
                'timestamp'   : '<?php echo time();?>',
                'token'       : '<?php echo md5('unique_salt'.time()); ?>'
            },
            'swf': '<?php echo $this->baseUrl; ?>/upload/js/uploadify/uploadify.swf',
            'uploader': '<?php echo Yii::app()->createAbsoluteUrl('uploadify/basicExecute')?>',
            'onUploadStart': function(file) {
                $('#uploadify').uploadify('settings', 'formData', {
                    'iswatermark': $("#iswatermark").attr("checked")
                });
            },
            'onUploadSuccess': function(file, data, response) {
                var json = $.parseJSON(data);
                if (json.state == 'success') {
                    $("#fileListWarp").html('<li id="image_' + json.fileId + '"><img src="<?php echo Yii::app()->homeUrl ?>'+json.file+'" width="40" height="40"  align="absmiddle"/></a>&nbsp;<a href="javascript:uploadifyRemove(&quot;' + json.fileId + '&quot;,&quot;image_&quot;)">删除</a><input name="'+Name+'" id="'+Name+'" type="hidden" value="'+json.file+'"/><br/></li>');
                } else {
                    alert(json.message);
                }
            }
        });
    });



    function uploadifyRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $.post(
                "<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/remove"); ?>",
                {imageId:fileId},
                function(res){
                    $("#"+attrName+fileId).remove();
                    art.dialog.data('fileListWarp',$("#"+Warp).html());
                },
                'json'
            );
        }
    }


</script>
